-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add noise hits to reconstructed hits by randomly generating cell id #1643
base: main
Are you sure you want to change the base?
Conversation
std::random_device rd; // Obtain a random number from hardware | ||
std::mt19937_64 eng(rd()); // Seed the generator | ||
std::uniform_int_distribution<uint64_t> distr; // Define the range for 64-bit integers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not create a new random device for every hit.
#if EDM4EIC_VERSION_MAJOR >= 7 | ||
auto rec_hit = | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if EDM4EIC_VERSION_MAJOR >= 7 | |
auto rec_hit = | |
#endif |
Not needed if you don't need to set a relation.
//------------------------------------------------ | ||
// Example code of adding random noise hits | ||
// Shujie Li, 08.2024 | ||
// use the first raw hits to obtain the volume ID of the detector system | ||
// this also make sure the hit container has at least one hit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//------------------------------------------------ | |
// Example code of adding random noise hits | |
// Shujie Li, 08.2024 | |
// use the first raw hits to obtain the volume ID of the detector system | |
// this also make sure the hit container has at least one hit | |
// Use the first raw hits to obtain the volume ID of the detector system. | |
// This also make sure the hit container has at least one hit. |
And add your name on the second line of the file.
std::random_device rd; // Obtain a random number from hardware | ||
std::mt19937_64 eng(rd()); // Seed the generator | ||
std::uniform_int_distribution<uint64_t> distr; // Define the range for 64-bit integers | ||
dd4hep::Position pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dd4hep::Position pos; |
uint64_t randomNum = distr(eng); // Generate a random 64-bit number | ||
randomNum = (randomNum & ~uint64_t(0xFF)) | vol_id; // Clear the last 8 bits and set them to 'vol ID' | ||
try { | ||
pos = m_converter->position(randomNum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pos = m_converter->position(randomNum); | |
auto pos = m_converter->position(randomNum); |
// std::cout<<"::: cell ID error caught"<<std::endl; | ||
nn++; | ||
} | ||
std::cout <<std::bitset<8>(vol_id) <<":"<< i<<"/"<<nn<<":::"<<randomNum<<" "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove "cout" output (even commented), or replace with clearly worded debug logging.
int nn=0; | ||
int i=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give clear name to the variables.
int nn=0; | |
int i=0; | |
unsigned int num_failures = 0; | |
unsigned int num_generated_hits = 0; |
uint64_t id0,vol_id; | ||
id0 = hit0.getCellID(); | ||
// vol ID is the last 8 bits in Si tracker. Need to make it more flexible | ||
// may want to predefine the layer/module ID as well to speed up the radom ID generation | ||
vol_id = id0 & 0xFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not call it "system ID"?
uint64_t id0,vol_id; | |
id0 = hit0.getCellID(); | |
// vol ID is the last 8 bits in Si tracker. Need to make it more flexible | |
// may want to predefine the layer/module ID as well to speed up the radom ID generation | |
vol_id = id0 & 0xFF; | |
uint64_t id0, system_id; | |
id0 = hit0.getCellID(); | |
// system ID is the last 8 bits in Si tracker. Need to make it more flexible | |
// may want to predefine the layer/module ID as well to speed up the radom ID generation | |
system_id = id0 & 0xFF; |
uint64_t randomNum = distr(eng); // Generate a random 64-bit number | ||
randomNum = (randomNum & ~uint64_t(0xFF)) | vol_id; // Clear the last 8 bits and set them to 'vol ID' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how this is clear and simple, but is performance terrible or not?
// use the first raw hits to obtain the volume ID of the detector system | ||
// this also make sure the hit container has at least one hit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this something that you really want or just a consequence of how you're getting the volume? Might it not be better to have a completely separate algorithm which constructs these hits from knowledge of the readout structure to get the volume rather than relying on their being a hit.
Briefly, what does this PR introduce?
add noise hits to reconstructed hits by randomly generating cell id.
for test only. The generated cell ID is not always on sensitive surface.
What kind of change does this PR introduce?
Please check if this PR fulfills the following:
Does this PR introduce breaking changes? What changes might users need to make to their code?
Does this PR change default behavior?